Skip to content

libgpiod: Make Python bindings optional#29165

Open
ernestask wants to merge 2 commits intoopenwrt:masterfrom
ernestask:conditional-deps
Open

libgpiod: Make Python bindings optional#29165
ernestask wants to merge 2 commits intoopenwrt:masterfrom
ernestask:conditional-deps

Conversation

@ernestask
Copy link
Copy Markdown

@ernestask ernestask commented Apr 16, 2026

📦 Package Details

Maintainer: @mhei

Description:
python3-gpiod causes python3-light to be built even if not selected, which can be avoided by making the dependency conditional`.

How to test:

  1. Select gpiod-tools
  2. make package/libgpiod/compile

Without the changes: python3 (and bluez) get built as dependencies
With the changes: python3 is not built


🧪 Run Testing Details

  • OpenWrt Version: 9247eb400241cd2b6f3ec141744b560dcf59c8db
  • OpenWrt Target/Subtarget: mediatek/filogic
  • OpenWrt Device: openwrt-one

✅ Formalities

  • I have reviewed the CONTRIBUTING.md file for detailed contributing guidelines.

Copy link
Copy Markdown
Member

@pprindeville pprindeville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nix on the isc-dhcp changes.

Comment thread net/isc-dhcp/Makefile Outdated
+bind-server \
+bind-rndc \
+bind-client
+PACKAGE_isc-dhcp-dyndns:bind-server \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this. Look at the install directions for this package. It doesn't do anything but make sure dependencies are satisfied. It's a meta-package. Making the dependencies conditional would defeat the purpose of having it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The install section is irrelevant here, but perhaps I haven’t expressed myself properly, so let me try to explain my problem again

scripts/package-metadata.pl will parse the package and spit out a line like this to tmp/.packagedeps (which is then used for ordering builds):

$(curdir)/feeds/packages/isc-dhcp/compile += $(curdir)/feeds/packages/bind/compile $(curdir)/libs/toolchain/compile $(curdir)/libs/zlib/compile

That means that if I select, say PACKAGE_isc-dhcp-relay-ipv6, in my config and leave PACKAGE_isc-dhcp-dyndns unselected, bind will still be built as a build dependency.

With the change, it would look more like this:

$(curdir)/feeds/packages/isc-dhcp/compile += $(curdir)/libs/toolchain/compile $(curdir)/libs/zlib/compile $(if $(CONFIG_PACKAGE_isc-dhcp-dyndns),$(curdir)/feeds/packages/bind/compile)

…and my build times would become ever-so-slightly shorter (the worse offender in my case is libgpiod with Python).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An existing example: 0c245fd

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not getting it. All of this is inside the definition of the subpackage isc-dhcp-dyndns so why would any of it take effect if that package isn't already selected? Isn't what you're doing redundant?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to how the package scripts work overall, it’s not redundant, unfortunately. All of the (sub-)package dependencies within a Makefile are collected and become implicit build dependencies, whether a particular subpackage is enabled or not (just picking any one is enough, because they are per-directory).

It could be “fixed” (it’s not a bug per se, more a build time optimization) by doing the same for all packages by default, but quite a few packages unknowingly rely on implicit behavior and would need fixing to get dependencies right, so I’m cherry-picking individual package changes I made.

It’s pretty much only noticable when building n+1 times a day and looking at the make output.

@ernestask ernestask changed the title isc-dhcp/libgpiod: Make dependencies conditional libgpiod: Make Python bindings optional Apr 17, 2026
@mhei
Copy link
Copy Markdown
Member

mhei commented Apr 17, 2026

The libgpiod changes LGTM for a first quick look, will have a deeper one today evening or tomorrow.

Comment thread libs/libgpiod/Makefile Outdated
else
CONFIGURE_ARGS += --disable-bindings-python
endif

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part does not work well: the python bindings are disabled by default and there is no auto-magic to enable them. On the other hand, passing --enable-bindings-python does not work for me in my local build: the build pulls in host python and fails to build. This is why the whole python build magic is wrapped later with Py3Package,python3-gpiod which sets the correct build environment (but it is not set already during "normal" package build).
I think you should drop this chunk.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped.

Comment thread libs/libgpiod/Makefile
@ernestask ernestask force-pushed the conditional-deps branch 3 times, most recently from e61a910 to 2614c88 Compare April 27, 2026 11:13
@commodo
Copy link
Copy Markdown
Contributor

commodo commented May 1, 2026

Build failure is

2.1.3 -Wl,-z,max-page-size=4096 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -Wl,-z,pack-relative-relocs " PYO3_CROSS_LIB_DIR="/builder/staging_dir/target-i386_pentium-mmx_musl/usr/lib/python3.14" SETUPTOOLS_RUST_CARGO_PROFILE="release"  LINK_SYSTEM_LIBGPIOD=1  /builder/staging_dir/hostpkg/bin/python3.14  -m build --no-isolation --outdir "/builder/build_dir/target-i386_pentium-mmx_musl/libgpiod-2.1.3/bindings/python"/openwrt-build --wheel   "/builder/build_dir/target-i386_pentium-mmx_musl/libgpiod-2.1.3/bindings/python" 
2026-04-27T14:20:14.9724038Z * Getting build dependencies for wheel...
2026-04-27T14:20:15.2175629Z 
2026-04-27T14:20:15.2176203Z Traceback (most recent call last):
2026-04-27T14:20:15.2176863Z   File "/builder/staging_dir/hostpkg/lib/python3.14/site-packages/pyproject_hooks/_impl.py", line 402, in _call_hook
2026-04-27T14:20:15.2177437Z     raise BackendUnavailable(
2026-04-27T14:20:15.2177661Z     ...<4 lines>...
2026-04-27T14:20:15.2177835Z     )
2026-04-27T14:20:15.2178147Z pyproject_hooks._impl.BackendUnavailable: Cannot import 'setuptools.build_meta'
2026-04-27T14:20:15.2178460Z 
2026-04-27T14:20:15.2178939Z ERROR Backend 'setuptools.build_meta:__legacy__' is not available.
2026-04-27T14:20:15.2351045Z make[2]: *** [Makefile:170: /builder/build_dir/target-i386_pentium-mmx_musl/libgpiod-2.1.3/.built] Error 1
2026-04-27T14:20:15.2351674Z make[2]: Leaving directory '/feed/libs/libgpiod'
2026-04-27T14:20:15.2354215Z time: package/feeds/packages_ci/libgpiod/compile#55.80#9.30#23.15
2026-04-27T14:20:15.2363399Z     ERROR: package/feeds/packages_ci/libgpiod failed to build.
2026-04-27T14:20:15.2370690Z make[1]: *** [package/Makefile:188: package/feeds/packages_ci/libgpiod/compile] Error 1
2026-04-27T14:20:15.2371385Z make[1]: Leaving directory '/builder'
2026-04-27T14:20:15.2376162Z make: *** [/builder/include/toplevel.mk:226: package/libgpiod/compile] Error 2
2026-04-27T14:20:15.2380511Z ##[group]  make package/index

This may need a PKG_BUILD_DEPENDS:=python-setuptools/host addition.

ernestask and others added 2 commits May 1, 2026 12:03
The python3-light dependency gets lugged even with the package disabled,
so this commit makes python3-light a conditional dependency, similar to
gensio in 0c245fd.

Signed-off-by: Ernestas Kulik <ernestas.k@iconn-networks.com>
If python3-gpiod is enabled and the python-setuptools host package is
missing, the setuptools.build_meta import will cause a build failure.
Fix this by adding a conditional build dependency.
@ernestask ernestask force-pushed the conditional-deps branch from 2614c88 to 5f9f70c Compare May 1, 2026 09:03
@ernestask
Copy link
Copy Markdown
Author

Build failure is

2.1.3 -Wl,-z,max-page-size=4096 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -Wl,-z,pack-relative-relocs " PYO3_CROSS_LIB_DIR="/builder/staging_dir/target-i386_pentium-mmx_musl/usr/lib/python3.14" SETUPTOOLS_RUST_CARGO_PROFILE="release"  LINK_SYSTEM_LIBGPIOD=1  /builder/staging_dir/hostpkg/bin/python3.14  -m build --no-isolation --outdir "/builder/build_dir/target-i386_pentium-mmx_musl/libgpiod-2.1.3/bindings/python"/openwrt-build --wheel   "/builder/build_dir/target-i386_pentium-mmx_musl/libgpiod-2.1.3/bindings/python" 
2026-04-27T14:20:14.9724038Z * Getting build dependencies for wheel...
2026-04-27T14:20:15.2175629Z 
2026-04-27T14:20:15.2176203Z Traceback (most recent call last):
2026-04-27T14:20:15.2176863Z   File "/builder/staging_dir/hostpkg/lib/python3.14/site-packages/pyproject_hooks/_impl.py", line 402, in _call_hook
2026-04-27T14:20:15.2177437Z     raise BackendUnavailable(
2026-04-27T14:20:15.2177661Z     ...<4 lines>...
2026-04-27T14:20:15.2177835Z     )
2026-04-27T14:20:15.2178147Z pyproject_hooks._impl.BackendUnavailable: Cannot import 'setuptools.build_meta'
2026-04-27T14:20:15.2178460Z 
2026-04-27T14:20:15.2178939Z ERROR Backend 'setuptools.build_meta:__legacy__' is not available.
2026-04-27T14:20:15.2351045Z make[2]: *** [Makefile:170: /builder/build_dir/target-i386_pentium-mmx_musl/libgpiod-2.1.3/.built] Error 1
2026-04-27T14:20:15.2351674Z make[2]: Leaving directory '/feed/libs/libgpiod'
2026-04-27T14:20:15.2354215Z time: package/feeds/packages_ci/libgpiod/compile#55.80#9.30#23.15
2026-04-27T14:20:15.2363399Z     ERROR: package/feeds/packages_ci/libgpiod failed to build.
2026-04-27T14:20:15.2370690Z make[1]: *** [package/Makefile:188: package/feeds/packages_ci/libgpiod/compile] Error 1
2026-04-27T14:20:15.2371385Z make[1]: Leaving directory '/builder'
2026-04-27T14:20:15.2376162Z make: *** [/builder/include/toplevel.mk:226: package/libgpiod/compile] Error 2
2026-04-27T14:20:15.2380511Z ##[group]  make package/index

This may need a PKG_BUILD_DEPENDS:=python-setuptools/host addition.

Added a commit to fix that. Though I believe the issue was already present before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants